<template>
  <div>
      <!-- readonly shallowreadonly-->
      <h1>{{obj.a}}</h1>
      <h1>{{obj.b.c}}</h1>
      <button @click="getValue">按钮</button>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, readonly, shallowReadonly } from 'vue'

export default defineComponent({
  setup () {
    const obj=reactive({
      a:1,
      b:{
        c:2
      }
    })
    // readonly只读属性 只能读 不能更改
    const roObj=readonly(obj)
    // shallowreadonly第一次只读不能更改 第二层第三层可以更改
    const soObj=shallowReadonly(obj)
    const getValue=()=>{
      console.log(obj.a)
      console.log(obj.b.c)
      console.log(roObj.a)
      // roObj.a++
      soObj.b.c++
    }
    return {
      obj,
      getValue,
    }
  }
})
</script>

<style scoped>

</style>